package leetcode.top100;

import org.junit.Test;

/**
 * @author ：zsy
 * @date ：Created 2022/12/22 5:44 PM
 * @description：
 */
public class _053_最大子数组和 {
    @Test
    public void test() {

    }

    class Solution {
        public int maxSubArray(int[] nums) {
            int ans = nums[0];
            for (int i = 1; i < nums.length; i++) {
                if (nums[i - 1] > 0) {
                    nums[i] += nums[i - 1];
                }
                ans = Math.max(ans, nums[i]);
            }
            return ans;
        }
    }
}
